package com.ruoyi.demooo1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.demooo1.domain.OneDayDivination;
import com.ruoyi.demooo1.mapper.OneDayDivinationMapper;
import com.ruoyi.demooo1.service.IOneDayDivinationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 每日一卦Service业务层处理
 *
 * @author ted
 * @date 2023-08-22
 */
@Service
public class OneDayDivinationServiceImpl extends ServiceImpl<OneDayDivinationMapper,OneDayDivination> implements IOneDayDivinationService {
    @Autowired
    private OneDayDivinationMapper oneDayDivinationMapper;

    /**
     * 查询每日一卦
     *
     * @param id 每日一卦主键
     * @return 每日一卦
     */
    @Override
    public OneDayDivination selectOneDayDivinationById(String id) {
        return oneDayDivinationMapper.selectOneDayDivinationById(id);
    }

    /**
     * 查询每日一卦列表
     *
     * @param oneDayDivination 每日一卦
     * @return 每日一卦
     */
    @Override
    public List<OneDayDivination> selectOneDayDivinationList(OneDayDivination oneDayDivination) {
        return oneDayDivinationMapper.selectOneDayDivinationList(oneDayDivination);
    }

    /**
     * 新增每日一卦
     *
     * @param oneDayDivination 每日一卦
     * @return 结果
     */
    @Override
    public int insertOneDayDivination(OneDayDivination oneDayDivination) {
        Date nowDate = DateUtils.getNowDate();
        Long userId = SecurityUtils.getUserId();
        oneDayDivination.setCreateTime(nowDate);
//        oneDayDivination.setId(UUID.randomUUID().toString().replace("-", ""));
        oneDayDivination.setUpdateTime(nowDate);
        oneDayDivination.setCreateBy(userId.toString());
        oneDayDivination.setUpdateBy(userId.toString());
        return oneDayDivinationMapper.insertOneDayDivination(oneDayDivination);
    }

    /**
     * 修改每日一卦
     *
     * @param oneDayDivination 每日一卦
     * @return 结果
     */
    @Override
    public int updateOneDayDivination(OneDayDivination oneDayDivination) {
        oneDayDivination.setUpdateTime(DateUtils.getNowDate());
        return oneDayDivinationMapper.updateOneDayDivination(oneDayDivination);
    }

    /**
     * 批量删除每日一卦
     *
     * @param ids 需要删除的每日一卦主键
     * @return 结果
     */
    @Override
    public int deleteOneDayDivinationByIds(String[] ids) {
        return oneDayDivinationMapper.deleteOneDayDivinationByIds(ids);
    }

    /**
     * 删除每日一卦信息
     *
     * @param id 每日一卦主键
     * @return 结果
     */
    @Override
    public int deleteOneDayDivinationById(String id) {
        return oneDayDivinationMapper.deleteOneDayDivinationById(id);
    }
}
